package com.zookeeper.component;

import com.zookeeper.ZkConnect;
import com.zookeeper.util.ZkOperateUtil;

import javax.swing.*;

/**
 * Created by whuanghkl on 17/5/31.
 */
public class DelButton extends MyButton {
    @Override
    public void action(String nodeKey) {
        System.out.println("nodeKey :" + nodeKey);
        int result = JOptionPane.showConfirmDialog(null, "确认要删除吗 ?", "确认",
                JOptionPane.OK_CANCEL_OPTION);
        if (result != JOptionPane.OK_OPTION) {
            return;
        }
        String rootPath = getRootPath();
        ZkConnect zooKeeper = getZkConnect();
        if (ZkOperateUtil.deleteZkNode(nodeKey, rootPath, zooKeeper)) {
            callback();
        }


    }


    public DelButton(String nodeKey) {
        super("删除", nodeKey);
        super.bindEvent();
    }

    public void callback() {
    }
}
